package com.aaa.mrcai.service.impl;

import com.aaa.mrcai.mapper.BusinessMapper;
import com.aaa.mrcai.pojo.entity.BussinessInfo;

import com.aaa.mrcai.pojo.vo.BusinessVO;
import com.aaa.mrcai.query.BussinessInfoQuery;
import com.aaa.mrcai.result.AjaxResult;
import com.aaa.mrcai.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ Author: Lining
 * @ Date: 2021/12/3 15:20
 */
@Service
public class BusinessServiceImpl implements BusinessService {

    @Autowired
    private BusinessMapper businessMapper;

    @Override
    public AjaxResult list(BussinessInfoQuery bussinessInfoQuery) {

        List<BussinessInfo> list = businessMapper.list(bussinessInfoQuery);
        Long aLong = businessMapper.queryBusinessTotalCount(bussinessInfoQuery);
        Map<String, Object> map = new HashMap<>();
        map.put("currentPageData",list);
        map.put("currentDataTotal",aLong);
        return AjaxResult.success(map);

    }

    @Override
    public AjaxResult getOne(int id) {
        BussinessInfo one = businessMapper.getOne(id);
        return AjaxResult.success(one);
    }

    @Override
    public AjaxResult listInfo(int bid) {
        BussinessInfo bussinessInfo = businessMapper.listInfo(bid);
        return AjaxResult.success(bussinessInfo);
    }

    @Override
    public AjaxResult uploadBicon(BusinessVO businessVO) {
        int i = businessMapper.uploadBicon(businessVO);
        if(i>0){
            return AjaxResult.success();
        }
        return AjaxResult.defeated();
    }

    @Override
    public AjaxResult updateInfo(BusinessVO businessVO) {
        int i = businessMapper.updateInfo(businessVO);
        if(i>0){
            return AjaxResult.success();
        }
        return AjaxResult.defeated();
    }
}
